﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;

using Spring.Globalization;

namespace Pg.BioMedics.SDR.Web.Formatters
{
    public class DateTimeFormatter : IFormatter
    {

        #region IFormatter Members

        public string Format(object value)
        {
            if (value is DateTime)
                return ((DateTime)value).ToString("yyyy/MM/dd hh:mm:ss", CultureInfo.InvariantCulture);
            else
                return String.Empty;
        }

        public object Parse(string value)
        {
            DateTime result = default(DateTime);
            if (DateTime.TryParse(value, out result))
                return result;
            else
                return null;
        }

        #endregion
    }
}
